#!/usr/bin/python

import sys
import os
import re

for line in os.popen("adb devices").readlines()[1:]:
    match=re.match("[0-9A-Za-z]+", line)
    if match:
        for arg in sys.argv[1:]:
            os.system("adb -s {0} install -r {1}".format(match.group(0), arg))

